package org.zasadnyy.redlions.players.server.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TournamentObject implements Serializable {

	private static final long serialVersionUID = -6022084229543548512L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;

	@Persistent
	private String title;

	@Persistent
	private String url;

	@Persistent
	private Date time;
	
	@Persistent
	private Set<Key> players = new HashSet<Key>();

	public TournamentObject() {
	}

	public TournamentObject(String title, String url, Date time) {
		super();
		this.title = title;
		this.url = url;
		this.time = time;
	}
	
	public TournamentObject(Key id, String title, String url, Date time, Set<Key> players) {
		super();
		this.id = id;
		this.title = title;
		this.url = url;
		this.time = time;
		this.players = players;
	}

	public Key getId() {
		return id;
	}

	public void setId(Key id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public void setPlayers(Set<Key> players) {
		this.players = players;
	}

	public Set<Key> getPlayers() {
		return players;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Tournament [id=").append(id).append(", title=")
				.append(title).append(", url=").append(url).append(", time=")
				.append(time).append("]");
		return builder.toString();
	}

}
